package cn.yiyuan.base.until;

import cn.yiyuan.auth.entity.EmpEntity;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.internet.MimeMessage;

/**
 * @user m
 * @project car_mall_system
 * @date 2023-12-28
 * @package cn.yiyuan.base.until
 */
@Component
@Data
public class Email {
    @Autowired
    private JavaMailSender javaMailSender;

    private Long id;  // 新增字段


    public void email(String string , String message) throws Exception{
        //创建复杂邮件对象
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
        //发送复杂邮件的工具类
        MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true,"utf-8");
        // 发件人
        helper.setFrom("15085393664@163.com");

        // 主题
        helper.setSubject("店铺激活");

        // 邮件的正文
        /*helper.setText("<h1>新型冠状病毒防护守则</h1>"+
                "<img src='http://img30.360buyimg.com/popWaterMark/jfs/t1/67988/7/14094/232759/5db64acfE6ab2b09e/38b5cb3dc38b4b1f.jpg\"' />",
                true);*/
//        helper.setText("恭喜你,店铺信息审核通过,请点击激活链接及时激活!<a href='http://localhost:8081/shop/active'>点击激活!</a>",
//                true);
        helper.setText(message,
                true);
        //添加附件
        /*helper.addAttachment("狗狗.png",new File("C:\\Users\\EDY\\Desktop\\imgs\\1.png"));
        helper.addAttachment("压缩文件.rar", new File("C:\\Users\\EDY\\Desktop\\imgs.rar"));*/

        //收件人
        helper.setTo(string);

        javaMailSender.send(mimeMessage);
    }

}
